import { get } from 'lodash-es'

export class HMemberType {
  id?: string
  hotel_id?: string
  code?: string
  name?: string
  card_category?: 'time-limited' | 'counting'
  expired_days?: number
  limited?: number
  allow_update_expired_days?: boolean
  allow_update_limited?: boolean
  day_limited?: number
  reference?: string
  url?: string
  disabled?: boolean
  sequence?: number
  created_id?: string
  updated_id?: string
  created_at?: string
  updated_at?: string
  version?: number;
  [key: string]: any

  constructor(data?: HMemberType) {
    this.init(data)
  }
}

HMemberType.prototype.init = function init(data?: HMemberType) {
  this.id = get(data, 'id')
  this.hotel_id = get(data, 'hotel_id')
  this.code = get(data, 'code', '')
  this.name = get(data, 'name', '')
  this.card_category = get(data, 'card_category', 'time-limited')
  this.expired_days = get(data, 'expired_days')
  this.limited = get(data, 'limited', 0)
  this.allow_update_expired_days = get(data, 'allow_update_expired_days', false)
  this.allow_update_limited = get(data, 'allow_update_limited', false)
  this.day_limited = get(data, 'day_limited', 0)
  this.reference = get(data, 'reference', '')
  this.url = get(data, 'url', '')
  this.disabled = get(data, 'disabled', false)
  this.sequence = get(data, 'sequence', 1)
  this.created_id = get(data, 'created_id')
  this.updated_id = get(data, 'updated_id')
  this.created_at = get(data, 'created_at')
  this.updated_at = get(data, 'updated_id')
  this.version = get(data, 'version')
}
